POV-Ray : Newsgroups : povray.programming : mixing POV code with C++ : Re: POV source errors Server Time
29 Jul 2024 06:20:53 EDT (-0400)
  Re: POV source errors  
From: Nigel Stewart
Date: 14 Feb 1999 23:38:50
Message: <36c7a4da.0@news.povray.org>
>> DBL x = 2.0;
>> becomes
>> DBL x = (DBL) 2.0;
>>
>> Is there anything unreasonable or dangerous about doing this?
>
>It is unreasonable: DBL x = 2.0; is c acompletly legal and *well* readable
>statement. DBL x = (DBL) 2.0 is less readable.

    But the meaning is more precise.  I think the benefit of clarity and
    portability outweigh your concern - but that's entirely my opinion.

    While the first line says "I want 2.0 assigned to x", the second says
    "I knowingly want 2.0 converted to a DBL, and assigned to x".

    For example, if you use a float as an intermediate result, treat it as a
    double later, and wonder why you're not getting the expected precision -
    the explicit cast will be something of a clue.  Your preference is
    to be oblivious to truncation.

    It's a fine point, but I think it is more than just a platform/compiler
    quirk - in this case Microsoft have done something for a sound
    technical reason.  (I wish they'd do so more often!)


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.